<%-- 
    Document   : shop
    Created on : 15-nov.-2012, 14:30:39
    Author     : Anthares
--%>
<%@page session="false" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="jt" %>
<%@taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${locale}"/>
<fmt:setBundle basename="Languages.lang"/>

<core:set var="pagename" scope="request" value="shop"/>
<jt:layout pageTitle="Shop">
    <jsp:body>
        <form id="category-form" method="GET" action="<core:url value="/shop/categ"/>">
            <label><fmt:message key="shop.category"/> : <select id="category-select" name="category">
                    <option value="-1"><fmt:message key="shop.category.select"/></option>
                    <option value="0">-- <fmt:message key="shop.category.all"/> --</option>
                    <core:forEach items="${categoryList}" var="item">
                        <option value="${item.categId}">${item.traduction.libelle}</option>
                    </core:forEach>
                </select></label>
            <script>
                $("#category-select").change(function(){
                    if($("#category-select").val()==-1) return;
                    $("#category-form").submit();
                });
            </script>
        </form>
        <core:if test="${empty productList}">
            <p class="error-msg"><fmt:message key="shop.category.error"/></p>
        </core:if>
        <div id="masonry-container">
            <core:forEach items="${productList}" var="item">
                <div class="masonry-item">
                    <a class="wrapper"  href="<core:url value="/products?id=${item.prodId}"/>"><img src="<core:url value="${item.image}"/>"></a>
                    <div class="desc">
                        <p class="lib">${item.traduction.libelle}</p>
                        <p class="price"><fmt:formatNumber value="${item.reducedPrice}" type="currency"/></p>
                    </div>
                </div>
            </core:forEach>
        </div>
    </jsp:body>
</jt:layout>

